import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-06-12
 * Time: 16:43
 */
public class Deom21 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
            System.out.println("t1线程等待之前");
                synchronized (locker) {
                    try {
                        locker.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            System.out.println("t1线程等待结束");
        });
       Thread t2 = new Thread(() -> {
           System.out.println("t2线程唤醒t1线程之前");
           synchronized (locker) {
               try {
                   Thread.sleep(20000);
                   locker.notify();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
           System.out.println("t2线程唤醒结束");
       });
       t1.start();
       t2.start();
    }
}
